package com.beerq.view.friends;

import android.content.Context;

import com.alibaba.fastjson.JSONObject;
import com.beerq.util.AppConfig;
import com.beerq.util.BasicHttp;
import com.beerq.util.Constants;

import okhttp3.RequestBody;

/**
 * 作者：minj on 2017/10/25 15:09
 * 发脾气的管理类
 */
public class FriendsManager {

    /***
     * 发信息
     * @param context
     * @param vipId 用户id
     * @param content 内容
     * @param pic 图片地址
     * @param callback
     */
    public static void postInfo(Context context, int vipId, String content , String pic, BasicHttp.IMyCallBack callback){
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("VipId",vipId);
        jsonObject.put("Desc",content);
        jsonObject.put("Pics",pic);

        RequestBody requestBodyPost= AppConfig.getBasicRequestBody(context).add("Args",jsonObject.toJSONString()).build();
//

        BasicHttp.postExec(context, Constants.server_domain+"Vip/AddMySight",requestBodyPost,callback);
    }


    /***
     * 根据Id获取啤气动态
     * @param context
     * @param vipId
     * @param userId
     * @param pageIndex
     * @param pageSize
     * @param sightType 0按Id 1全部
     * @param callBack
     */
    public static void getFriendContentById(Context context, int vipId, int userId, int  pageIndex, int pageSize, int sightType, BasicHttp.IMyCallBack callBack){

        JSONObject jsonObject=new JSONObject();
//        jsonObject.put("SightId",sightId);
        jsonObject.put("VipId",vipId);
        jsonObject.put("AppUserId",userId);
        jsonObject.put("PageIndex",pageIndex);
        jsonObject.put("PageSize",pageSize);
        jsonObject.put("SightType",sightType);
//        RequestBody requestBodyPost=AppConfig.getBasicRequestBody(context).add("Args",jsonObject.toJSONString()).build();
        BasicHttp.getExec(context,Constants.server_domain+"Vip/MySightList?Args="+jsonObject.toJSONString()+"&Timestamp="+AppConfig.getTimeStamp(),callBack,true);



    }


    /***
     * 获得关注的好友列表信息
     * @param context
     * @param userId
     * @param sightType 0获取推荐  1获取我关注的  2获取我的啤气
     * @param callBack
     */

    public static void getSuggestFriend(Context context, int userId, int sightType, BasicHttp.IMyCallBack callBack){

        JSONObject jsonObject=new JSONObject();
//        jsonObject.put("SightId",sightId);
        jsonObject.put("AppUserId",userId);
        jsonObject.put("BrandId","1");
        jsonObject.put("SightType",sightType);
//        RequestBody requestBodyPost=AppConfig.getBasicRequestBody(context).add("Args",jsonObject.toJSONString()).build();
        BasicHttp.getExec(context,Constants.server_domain+"Vip/MySightReCommentList?Args="+jsonObject.toJSONString()+"&Timestamp="+AppConfig.getTimeStamp(),callBack,true);



    }


    /***
     * 点赞这条message
     * @param context
     * @param userId
     * @param sightId 这个信息的id
     * @param voteType 0是点赞 1是取消点赞
     * @param callback
     */
    public static void like(Context context, int userId, int sightId, int voteType, BasicHttp.IMyCallBack callback){

        if(sightId==0)return;

        JSONObject jsonObject=new JSONObject();
        jsonObject.put("AppUserId",userId);
        jsonObject.put("SightId",sightId);
        jsonObject.put("VoteType",voteType);

        RequestBody requestBodyPost= AppConfig.getBasicRequestBody(context).add("Args",jsonObject.toJSONString()).build();
        BasicHttp.postExec(context, Constants.server_domain+"Vip/AddMySightVote",requestBodyPost,callback);
    }

    public static void postComt(Context context, int vipId,int replyId,String content, int sightId, BasicHttp.IMyCallBack callback){

        if(vipId==0){
            return;
        }

        JSONObject jsonObject=new JSONObject();
        jsonObject.put("VipId",vipId);
        jsonObject.put("ComtReplyUserId",replyId);
        jsonObject.put("ComtReplyContent","");
        jsonObject.put("ComtPics","");
        jsonObject.put("CommentContent",content);
        jsonObject.put("ReplyTime","");
        jsonObject.put("SightId",sightId);

        RequestBody requestBodyPost= AppConfig.getBasicRequestBody(context).add("Args",jsonObject.toJSONString()).build();
        BasicHttp.postExec(context, Constants.server_domain+"Vip/AddMySightComment",requestBodyPost,callback);
    }

    /***
     * 删除动态
     * @param context
     * @param vipId
     * @param sightId
     * @param callBack
     */
    public static void deleteContent(Context context, int vipId, int sightId, BasicHttp.IMyCallBack callBack){
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("VipId",vipId);

        jsonObject.put("SightId",sightId);

//        RequestBody requestBodyPost=AppConfig.getBasicRequestBody(context).add("Args",jsonObject.toJSONString()).build();
        BasicHttp.getExec(context,Constants.server_domain+"Vip/DeleteMySight?Args="+jsonObject.toJSONString()+"&Timestamp="+AppConfig.getTimeStamp(),callBack,true);

    }

    /***
     *
     * @param context
     * @param vipId 关注人
     * @param followVipId 被关注人
     * @param isFocus 关注0 取关1
     * @param callBack
     */
    public static void focusFriends(Context context, int vipId,int followVipId, int isFocus, BasicHttp.IMyCallBack callBack){
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("VipId",vipId);
        jsonObject.put("FollowVipId",followVipId);
        jsonObject.put("IsFocus",isFocus);
        jsonObject.put("FocusType",1);//1关注   2拉黑

        RequestBody requestBodyPost= AppConfig.getBasicRequestBody(context).add("Args",jsonObject.toJSONString()).build();
        BasicHttp.postExec(context, Constants.server_domain+"Vip/MySightFocusOpt",requestBodyPost,callBack);

//        RequestBody requestBodyPost=AppConfig.getBasicRequestBody(context).add("Args",jsonObject.toJSONString()).build();
//        BasicHttp.getExec(context,Constants.server_domain+"Vip/MySightFocusOpt?Args="+jsonObject.toJSONString()+"&Timestamp="+AppConfig.getTimeStamp(),callBack,true);

    }


    /***
     * 我关注的人和我的粉丝
     * @param context
     * @param vipId
     * @param callBack
     */
    public static void getMyFavouriteAndLikes(Context context, int vipId, BasicHttp.IMyCallBack callBack){
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("AppUserId",vipId);
        BasicHttp.getExec(context,Constants.server_domain+"Vip/MySightRelationList?Args="+jsonObject.toJSONString()+"&Timestamp="+AppConfig.getTimeStamp(),callBack,false);

    }


    /***
     * 获得我关注的动态
     * @param context
     * @param vipId
     * @param callBack
     */
    public static void getMyFavouriteSight(Context context, int vipId, BasicHttp.IMyCallBack callBack){
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("AppUserId",vipId);
        jsonObject.put("PageIndex",1);
        jsonObject.put("PageSize",1000);

        BasicHttp.getExec(context,Constants.server_domain+"vip/MySightLikeList?Args="+jsonObject.toJSONString()+"&Timestamp="+AppConfig.getTimeStamp(),callBack,false);

    }


}
